package com.fmy.jurisdiction.core.web.specs;

import lombok.Data;

import java.io.Serializable;

/**
 * @version 1.0
 * @Author MR.fmy
 * @Description 返回规格定义类
 * 建议使用 SpringBoot 在返回JSON 序列化时 为NULL的字段
 * 不进行序列化、设置方法如下：在 application配置文件中加上
 * spring.jackson.default-property-inclusion: non_null
 * @Date 2019/5/15 0015 09:06
 **/
@Data
public class Response<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    private String code; //状态码
    private String errMsg; //只有发生异常时才会有值
    private String msg; //成功的提示
    private T data; //成功时返回的数据
    private Integer count; //分页时才显示

    public Response(String code, String errMsg) {
        this.code = code;
        this.errMsg = errMsg;
    }


    public Response(String code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public Response(String code, String msg, T data, Integer count) {
        this.code = code;
        this.msg = msg;
        this.data = data;
        this.count = count;
    }
}
